package com.pingan.haofang.searchcloud.common.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * TODO: 请添加描述
 *
 * @author liujunjun380
 * @date 2018/11/19
 * @since 1.0.0
 */
@Configuration
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolTaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
        // 线程池维护线程的最少数量
        pool.setCorePoolSize(10);
        // 线程池维护线程的最大数量
        pool.setMaxPoolSize(20);
        // 当调度器shutdown被调用时等待当前被调度的任务完成
        pool.setWaitForTasksToCompleteOnShutdown(true);
        pool.setThreadNamePrefix("redis-list-pop-");
        return pool;
    }
}
